/* This is to get
Table 3 */

clear all
estimates clear

global dopath "C:/Users/bogdanp/Dropbox/Legacies_Central_Europe"
*global dopath "/Users/bgpopescu/Dropbox/Legacies_Central_Europe"

use "$dopath/data/nuts_data.dta", clear
egen ctrnum1 = group(ctrnum)
drop ctrnum
gen ctrnum = ctrnum1
drop ctrnum1

/* education regressions */
**********
*TABLE 4*
*********

*gen otthist = 0 /* identifies countries wiht Ottoman history*/
*replace otthist = 1 if ctr=="AL"
*replace otthist = 1 if ctr=="BG" |ctr=="CY" |ctr=="EL" |ctr=="ES" |ctr=="HR" |ctr=="HU" |ctr=="IT" |ctr=="ME" |ctr=="MK" |ctr=="PL" | ctr=="RO" |ctr=="RS" |ctr=="SI" |ctr=="SK" 

label variable p_ottoman_1800 "Prop. Ottoman, 1800"
label variable p_ottoman_1700 "Prop. Ottoman, 1700"
label variable ps_1699 "Printshops, 1700"
label variable uni_1799 "Universities, 1800"

quietly poisson uni_1799 p_ottoman_1800 tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance if (ctr != "TR" & otthist==1), cluster (ctrnum)
*margins, at(p_ottoman_1800=.25)
*margins, at(p_ottoman_1800=.75)
eststo model1, title("Universities, 1800")
estadd local FE "No"
estadd local Controls "Yes"
estadd local Model "Poisson"

quietly poisson ps_1699 p_ottoman_1700 tavg lograin logelev logslope point_x point_y  wheat_rainfed log_sea_lines_distance log_large_rivers_distance if (ctr != "TR" & otthist==1), cluster (ctrnum)
*margins, at(p_ottoman_1700=.25)
*margins, at(p_ottoman_1700=.75)
eststo model2, title("Printshops, 1700")
estadd local FE "No"
estadd local Controls "Yes"
estadd local Model "Poisson"

quietly poisson uni_1799 p_ottoman_1800 tavg lograin logelev logslope point_x point_y wheat_rainfed log_sea_lines_distance log_large_rivers_distance i.ctrnum if (ctr != "TR" & otthist==1), cluster (ctrnum)
*margins, at(p_ottoman_1800=.25)
*margins, at(p_ottoman_1800=.75)
eststo model3, title("Universities, 1800")
estadd local FE "Yes"
estadd local Controls "Yes"
estadd local Model "Poisson"

quietly poisson ps_1699 p_ottoman_1700 tavg lograin logelev logslope point_x point_y  wheat_rainfed log_sea_lines_distance log_large_rivers_distance i.ctrnum if (ctr != "TR" & otthist==1), cluster (ctrnum)
*margins, at(p_ottoman_1700=.25)
*margins, at(p_ottoman_1700=.75)
eststo model4, title("Printshops, 1700")
estadd local FE "Yes"
estadd local Controls "Yes"
estadd local Model "Poisson"


quietly reg lngdpcap ps_1699 tavg lograin logelev logslope point_x point_y  wheat_rainfed log_sea_lines_distance log_large_rivers_distance i.ctrnum if (ctr != "TR" & otthist==1), cluster (ctrnum)
*margins, at(p_ottoman_1700=.25)
*margins, at(p_ottoman_1700=.75)
eststo model5, title("Log GDP/cap")
estadd local FE "Yes"
estadd local Controls "Yes"
estadd local Model "OLS"


quietly reg lngdpcap uni_1799 tavg lograin logelev logslope point_x point_y  wheat_rainfed log_sea_lines_distance log_large_rivers_distance i.ctrnum if (ctr != "TR" & otthist==1), cluster (ctrnum)
*margins, at(p_ottoman_1700=.25)
*margins, at(p_ottoman_1700=.75)
eststo model6, title("Log GDP/cap")
estadd local FE "Yes"
estadd local Controls "Yes"
estadd local Model "OLS"


esttab using "$dopath/Paper/tables/table3.tex",  ///
eqlabels(" " " ") b(3) booktabs mtitle label  ///
mtitles("Universities, 1800" "Printshops, 1700" "Universities, 1800" "Printshops, 1700" "Log GDP/cap" "Log GDP/cap")  ///
star(+ 0.10 * 0.05 ** 0.01 *** 0.001) keep(p_ottoman_1800 p_ottoman_1700 ps_1699 uni_1799) replace  ///
se stats(N FE Controls Model r2 aic ll, fmt(%15.0fc 0 %9.2f) ///
labels("Observations" "Country FE" "Controls" "Model" R-squared AIC "Log Likelihood")) ///	
nonotes addnotes("Note: All models are estimated on the sample of countries with Ottoman experience. Standard errors are clustered at the country level."  ///
"*** = p<.001; ** = p<.01, *=p<.05, +=p<.10.")
 	
